package com.jxd.repositories;

import com.jxd.entity.MesHead;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MesHeadRepositories extends ElasticsearchRepository<MesHead, String> {
    //自定义函数 根据文件名 报文类型 舷号获取内容
    List<MesHead> findAllByFileNameAndMesIdAndShipId(String fileName, String mesId, String shipId);

    List<MesHead> findAllByFileNameAndMesIdAndShipId(String fileName, String mesId, String shipId, Sort sort);

    List<MesHead> findAllByFileNameAndMesIdAndShipIdAndSendDevice(String fileName, String mesId, String shipId,String receivingDevice);
    
    //自定义函数获取所有
    @Override
    List<MesHead> findAll();

    List<MesHead> findAll(Sort sort);

    List<MesHead> findAllByFileNameAndShipId(String filename, String shipid, Sort sort);

    //  List<MesHead>findByFileNameOrderBymesSignIdDesc(String filename);
    //自定义函数 根据id获取内容
    MesHead findAllById(String id);

    //根据报文类型获取
    List<MesHead> findAllByMesId(String mesId);

    //在什么之前
    List<MesHead> findAllByMesSignIdBeforeAndFileNameAndShipId(Long mesSignId, String fileName, String shipId);

    //流程间的所有报文
    List<MesHead> findAllByMesSignIdBetween(Long stmesSignId, Long endmesSignId);

    //获取所有的维护反馈报文
    List<MesHead> findAllByFileNameAndShipIdOrMesIdOrMesIdOrMesIdOrMesId(
            String filename, String shipid, String mesid1, String mesid2, String mesid3, String mesid4
    );

    //根据发送设备和报文类型获取数据
    List<MesHead> findAllByFileNameAndShipIdAndSendDeviceAndMesId(
            String filename,
            String shipid,
            String sendDevice,
            String mesId,
            Sort sort);
    
  //自定义函数 根据文件名 报文类型 舷号 报文头信息标志获取内容
    List<MesHead> findAllByFileNameAndMesIdAndShipIdAndReceivingDeviceAndSendDevice(
    		String fileName, String mesId, String shipId, String receivingDevice, String sendDevice, Sort sort);
    
    List<MesHead> findAllByFileNameAndMesIdAndShipIdAndReceivingDeviceAndSendDeviceAndMesSignIdAfter(
    		String fileName, String mesId, String shipId, String receivingDevice, String sendDevice, String mesSignId,Sort sort);
    
    List<MesHead> findAllByFileNameAndMesIdAndShipIdAndReceivingDeviceAndSendDeviceAndMesSignIdBefore(
    		String fileName, String mesId, String shipId, String receivingDevice, String sendDevice, String mesSignId,Sort sort);
    
    List<MesHead> findAllByFileNameAndMesIdAndMesSignIdBefore(
    		String fileName, String mesId, String mesSignId,Sort sort);

    void deleteByMesSignId(long mesSignId);
    //分页查询
    Page<MesHead> getAllByMesIdOrMesIdOrMesIdOrMesId(String mesid1,String mesid2,String mesid3,String mesid4, Pageable pageable);


}
